package com.dfbz.springboot_project.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.ibatis.annotations.Options;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Objects;

@Entity
@Table(name = "admin_info", schema = "netctoss")
public class AdminInfo {
    @KeySql(useGeneratedKeys = true)
    @Id
    private Integer adminId;
    private String adminCode;
    private String adminPassword;
    private String adminName;
    private String adminTelephone;
    private String adminEmail;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "CTT")
    private Date adminEnrolldate;
    @Transient
    private String roles;

    public String getRoles() {
        return roles;
    }

    public void setRoles(String roles) {
        this.roles = roles;
    }

    @Id
    @Column(name = "admin_id", nullable = false)
    public Integer getAdminId() {
        return adminId;
    }

    public void setAdminId(Integer adminId) {
        this.adminId = adminId;
    }

    @Basic
    @Column(name = "admin_code", nullable = false, length = 30)
    public String getAdminCode() {
        return adminCode;
    }

    public void setAdminCode(String adminCode) {
        this.adminCode = adminCode;
    }

    @Basic
    @Column(name = "admin_password", nullable = false, length = 32)
    public String getAdminPassword() {
        return adminPassword;
    }

    public void setAdminPassword(String adminPassword) {
        this.adminPassword = adminPassword;
    }

    @Basic
    @Column(name = "admin_name", nullable = false, length = 30)
    public String getAdminName() {
        return adminName;
    }

    public void setAdminName(String adminName) {
        this.adminName = adminName;
    }

    @Basic
    @Column(name = "admin_telephone", nullable = true, length = 30)
    public String getAdminTelephone() {
        return adminTelephone;
    }

    public void setAdminTelephone(String adminTelephone) {
        this.adminTelephone = adminTelephone;
    }

    @Basic
    @Column(name = "admin_email", nullable = true, length = 50)
    public String getAdminEmail() {
        return adminEmail;
    }

    public void setAdminEmail(String adminEmail) {
        this.adminEmail = adminEmail;
    }


    @Basic
    @Column(name = "admin_enrolldate", nullable = false)
    public Date getAdminEnrolldate() {
        return adminEnrolldate;
    }

    public void setAdminEnrolldate(Date adminEnrolldate) {
        this.adminEnrolldate = adminEnrolldate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AdminInfo adminInfo = (AdminInfo) o;
        return adminId == adminInfo.adminId &&
                Objects.equals(adminCode, adminInfo.adminCode) &&
                Objects.equals(adminPassword, adminInfo.adminPassword) &&
                Objects.equals(adminName, adminInfo.adminName) &&
                Objects.equals(adminTelephone, adminInfo.adminTelephone) &&
                Objects.equals(adminEmail, adminInfo.adminEmail) &&
                Objects.equals(adminEnrolldate, adminInfo.adminEnrolldate);
    }

    @Override
    public String toString() {
        return "AdminInfo{" +
                "adminId=" + adminId +
                ", adminCode='" + adminCode + '\'' +
                ", adminPassword='" + adminPassword + '\'' +
                ", adminName='" + adminName + '\'' +
                ", adminTelephone='" + adminTelephone + '\'' +
                ", adminEmail='" + adminEmail + '\'' +
                ", adminEnrolldate=" + adminEnrolldate +
                '}';
    }

    @Override
    public int hashCode() {
        return Objects.hash(adminId, adminCode, adminPassword, adminName, adminTelephone, adminEmail, adminEnrolldate);
    }
}
